<?php

class StringHelpers{
	/**
	 * Helper function to pluralize singular english words
	 * @param string $name
	 */
	public static function pluralize($name){
		$rules=array(
                        '/(x|ch|ss|sh|us|as|is|os)$/i' => '\1es',
                        '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
                        '/(m)an$/i' => '\1en',
                        '/(child)$/i' => '\1ren',
                        '/(r|t)y$/i' => '\1ies',
                        '/s$/' => 's',
		);
		foreach($rules as $rule=>$replacement)
		{
			if(preg_match($rule,$name))
			return preg_replace($rule,$replacement,$name);
		}
		return $name.'s';
	}
}